package pl.qsoft.db.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import pl.qsoft.db.storedProc.intercept.BasicInvocationInterceptor;
import pl.qsoft.db.storedProc.intercept.InvocationInterceptor;


/**
 * Annotation interface for describing methods that represent stored procedure of a defined type
 * @author Wojciech Kudla
 * @see StoredProcedureDefinition
 *
 */

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface StoredProcedure {
	
	/**
	 * Enumeration for caching policy. Three modes are supported:
	 * <li>REFERENCE - caching is enabled and a reference to the cached object is returned</li>
	 * <li>CLONED - caching is enabled and cached object's deep copy is returned</li>
	 * <li>DISABLED - result caching is disabled</li> 
	 * @author Wojciech Kudla
	 */
	public enum CachePolicy { REFERENCE, CLONED, DISABLED }

	/**
	 * Mandatory property pointing to a definition of a stored procedure to be called
	 */
	Class procedureDefinition();
	
	/**
	 * Property for defining a custom InvocationInterceptor class that will have its beforeInvoke() and afterInvoke() methods called during stored procedure invocation
	 * @see InvocationInterceptor 
	 */
	Class<? extends InvocationInterceptor> invocationInterceptor() default BasicInvocationInterceptor.class;
	
	/**
	 * A boolean property defining whether procedure call results should be cached or not 
	 */
	CachePolicy cachePolicy() default CachePolicy.DISABLED;
}
